#https://www.luogu.com.cn/problem/P1097
#AC
N=readline.to_i
nums=Hash.new(0)
for seq in (1..N)
	i=readline.to_i
	nums[i]+=1
end
nums.sort.each{|k,v|
	puts "#{k} #{v}"
}

